package com.aizuda.encrypt.jsqlparse.visitor;

import com.aizuda.encrypt.jsqlparse.entity.JSQLCryptExpression;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
import net.sf.jsqlparser.expression.operators.relational.ItemsListVisitor;
import net.sf.jsqlparser.expression.operators.relational.MultiExpressionList;
import net.sf.jsqlparser.expression.operators.relational.NamedExpressionList;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.statement.select.SubSelect;

import java.util.List;


/**
 * in 列表项
 *
 * @author nn200433
 * @date 2022-03-02 06:49:28
 */
@Slf4j
public class ItemsListV extends VisitorHandle implements ItemsListVisitor {

    private Column leftExpression;
    private String sql;

    public ItemsListV(List<JSQLCryptExpression> list) {
        super(list);
    }

    public ItemsListV(List<JSQLCryptExpression> list, Column leftExpression, String sql) {
        super(list);
        this.leftExpression = leftExpression;
        this.sql            = sql;
    }

    @Override
    public void visit(SubSelect subSelect) {
        log.debug("---> [Mybatis SQL 解析拦截] SubSelect");
    }

    @Override
    public void visit(ExpressionList expressionList) {
        List<Expression> expressions = expressionList.getExpressions();
        for (Expression expression : expressions) {
            handler(this.leftExpression, expression, sql);
        }
        log.debug("---> [Mybatis SQL 解析拦截] ExpressionList");
    }

    @Override
    public void visit(NamedExpressionList namedExpressionList) {
        log.debug("---> [Mybatis SQL 解析拦截] NamedExpressionList");
    }

    @Override
    public void visit(MultiExpressionList multiExprList) {
        log.debug("---> [Mybatis SQL 解析拦截] MultiExpressionList");
    }

}
